# import socket
# import subprocess
#
# phone = socket.socket()
#
# phone.bind(('127.0.0.1', 8888))
#
# phone.listen(5)
#
# # 4. 接收连接
# print('start')
# conn, addr = phone.accept()
# while 1:
#     try:
#         cmd = conn.recv(1024)
#         obj = subprocess.Popen(cmd.decode('utf-8'),
#                                shell=True,
#                                stdout=subprocess.PIPE,
#                                stderr=subprocess.PIPE,
#                                )
#
#         result = obj.stdout.read() + obj.stderr.read()
#         print(f'服务端发送的总字节数{len(result)}')
#         conn.send(result)
#     except ConnectionResetError:
#         break
# conn.close()
# phone.close()
#
#
#

#
# import socket
# import subprocess
#
# phone = socket.socket()
#
# phone.bind(('127.0.0.1', 8888))
#
# phone.listen(5)
#
# # 4. 接收连接
# print('start')
# conn, addr = phone.accept()
# while 1:
#     try:
#         cmd = conn.recv(1024)
#         obj = subprocess.Popen(cmd.decode('utf-8'),
#                                shell=True,
#                                stdout=subprocess.PIPE,
#                                stderr=subprocess.PIPE,
#                                )
#
#         result = obj.stdout.read() + obj.stderr.read()
#         print(f'服务端发送的总字节数{len(result)}')
#         conn.send(result)
#     except ConnectionResetError:
#         break
# conn.close()
# phone.close()



# send端的黏包现象

import socket


phone = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

phone.bind(('127.0.0.1', 8080))

phone.listen()

conn, client_addr = phone.accept()

frist_data = conn.recv(1024)
print('1:',frist_data.decode('utf-8'))
second_data = conn.recv(1024)
print('2:',second_data.decode('utf-8'))


conn.close()
phone.close()

# 服务端

